<?php
/*
 * Created on 09.04.2007
 * @filesource: admin.schichtplan.html.php
 * @author: Nikolai Plath
 */


defined( '_VALID_MOS' ) or die( 'Direct Access to this script is not allowed');

class HTML_ExtensionIcons {
	function listItems ( $option, &$rows, &$pageNav ) {

    global $mosConfig_live_site;
    $number = count($rows);
//    echo $mosConfig_;
	echo '
      <script language="javascript" type="text/javascript">
         function submitbutton(pressbutton) {
           var form = document.adminForm;
           if (pressbutton == "cancel") {
              submitform( pressbutton );
              return;
           }
           submitform( pressbutton );
        }
     </script>
     <h2>Extension Icons</h2>
    <form action="index2.php" method="post" name="adminForm">
      <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
       <tr>
        <th width="20">
         <input type="checkbox" name="toggle" value="" onclick="checkAll('.$number.');"/>
        </th>
        <th align="left" width="20">Icon</th>
        <th align="left">Komponente</th>
        <th align="left" colspan="2" width="40">Sortieren</th>
        <th align="center" width="20">Published</th>
       </tr>';
        //$i = 0;
        $cnt = 0;
        //$n = count($rows);
//	foreach ($rows as $row)
//	{

		for ($i=0, $n=count( $rows ); $i < $n; $i++) {
			$row = &$rows[$i];


		$evenodd = $i % 2;
        $task 	= $row->published ? 'unpublish' : 'publish';
		$img 	= $row->published ? 'publish_g.png' : 'publish_x.png';
		$alt 	= $row->published ? 'Published' : 'Unpublished';

  		echo '
      <tr class="row'.$evenodd.'">
       <td>
        <input type="checkbox" id="cb'.$i.'" name="cid[]"
               value="'.$row->id.'"
               onclick="isChecked(this.checked);" />
       </td>
       <td>'
       	.'<img src="'.$mosConfig_live_site . '/includes/' . $row->admin_menu_img . '" />'
     .'</td>
        <td><strong>'.$row->parent_name.' </strong>'
        . '<a href="#edit" onclick="return listItemTask(\'cb'.$i.'\',\'edit\')">'
        .$row->name.'</a>
       </td>
      <td>';
	echo $pageNav->orderUpIcon( $i, ($row->catid == @$rows[$i-1]->catid) );
	echo '
		</td>
	  	<td>';
	echo $pageNav->orderDownIcon( $i, $n, ($row->catid == @$rows[$i+1]->catid) );

	echo '</td>';
	echo '<td align="center" >';
    echo '<a href="javascript: void(0);" onclick="return listItemTask(\'cb'. $i .'\',\'' . $task . '\')">
		<img src="images/' . $img . '" width="12" height="12" border="0" alt="' . $alt . '" /></a>';
    echo "</td></tr>";
          // $i++;
        }

	echo $pageNav->getListFooter();
  echo '
  		 </table>
      <input type="hidden" name="option"
             value="'.$option.'" />
      <input type="hidden" name="task" value="" />
      <input type="hidden" name="boxchecked" value="0" />
     </form>';
     }

  function edit( $option, &$row )
  {
global $mosConfig_live_site; ?>
  <script language="javascript" type="text/javascript">
        function submitbutton(pressbutton) {
           var form = document.adminForm;
           if (pressbutton == "cancel") {
              submitform( pressbutton );
              return;
           }
           submitform( pressbutton );
        }
     </script>
     <?php
echo '<form action="index2.php" method="post"
        name="adminForm" id="adminForm" class="adminForm">';

echo '<table class="adminheading">'
		.'<tr><th>Edit:<small>'
			. $row->parent_name.' '.$row->name
			. '</small></th>'
		.'</tr></table>';

echo '<table class="adminform">'
		.'<tr>'
			.'<td style="text-align:right"><strong>Published:</strong></td>'
			.'<td>'
			. mosHTML::yesnoRadioList( 'published', 'class="inputbox"', $row->published )
			.'</td>'
		.'</tr>';

echo '<tr valign="top">'.
 		'<td style="text-align:right"><strong>Icon:</strong>'
// 		.'<img src="'.$mosConfig_live_site . '/includes/' . $row->admin_menu_img . '" />
		.'</td>'
 		.'<td>';// .

$Pfad = '../includes/js/ThemeOffice/';
$sPfad = '/includes/js/ThemeOffice/';
//echo $Pfad;
$DD = dir($Pfad);
$icon_count = 0;
$icon_max   = 5;
echo '<table><tr><td>';
while (false !== ($entry = $DD->read()))
{
     if($entry != '.' && $entry != '..'
     	&& substr ($entry, strlen ($entry) -3) == 'png'
     	&& $entry != 'spacer.png'
     	&& $entry != 'blank.png')
     {
        //echo '<table>';
        echo '<label><input type="radio" name="admin_menu_img" value="js/ThemeOffice/' . $entry . '"';
       	if ('js/ThemeOffice/' . $entry == $row->admin_menu_img)
       	{
       		echo 'checked="checked"';
       	}
        echo		' />';
        echo '<img src="'.$mosConfig_live_site . $sPfad . $entry . '" />';
//        echo $entry;
		echo '</label><br /><br />';
		$icon_count += 1;
     }
     if ( $icon_count == $icon_max )
     {
     	echo '</td><td>';
     	$icon_count = 0;
     }
}
echo '</td></tr></table>';

echo
		'</td>' .
		'</tr>' .
		'</table>';

?>
     <input type="hidden" name="id" value="<?php echo $row->id; ?>" />
    <input type="hidden" name="option" value="<?php echo $option; ?>" />
    <input type="hidden" name="task" value="" />
   </form>

<?php



 }
	function printFooter ()
	{
		echo '<div class="smallgrey">Greetings from <a href="http://www.nik-it.de">NiK-IT.de</a></div>';
	}
  }
/*
function getcbuserfromid ( $dertag, $cbuserid )
{

	global $database;

	$query="SELECT * from #__comprofiler".
			"\n WHERE cb_hitradiostatus='DJ'";

	$database->setQuery($query);
	$cbusers=$database->loadObjectList();
 	echo '<select name="' . $dertag . '">';
    echo '<option value="0">Non Stop</option>';

	foreach ($cbusers as $cbuser)
	{
    echo '<option value="' . $cbuser->user_id . '"';

	if ($cbuser->user_id == $cbuserid)
	{
		echo ' selected="selected"';
	}

    echo '>' . $cbuser->cb_djname . '</option>';
	}
//    <option selected="selected">qwewqw</option>
  echo '</select>';

}

function getdjname ($djid)
{
	global $database;
	if ($djid == '0')
	{
		return "---";
	}
	$database->setQuery("SELECT cb_djname from #__comprofiler".
			"\n WHERE user_id='".$djid."'");
	return $database->loadResult();
}
*/
?>
